#include "nemu.h"
#include "monitor/monitor.h"
#include "monitor/watchpoint.h"

static FILE* trfd;
extern CPU_state cpu;
extern CPU_state orign_cpu;

void init_tracefile() {
  trfd = fopen("/home/lanfeng/develop/njeum/njemulator/nemu/build/trac.ans", "w");
  if(!trfd) {
      assert(0);
  }
}

void gen_trace() {
    // bool flag = true;;
    for(int i=0;i<32;i++) {
        if(cpu.gpr[i]._32 != orign_cpu.gpr[i]._32) {
            // flag = false;
            fprintf(trfd,"%x $%d %x\n",orign_cpu.pc,i,cpu.gpr[i]._32);
            break;
        }
    }
    
    // if(flag)
    //     fprintf(trfd,"\n");

}
